home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TeX 1995 July
/
TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO
/
tex-k
/
tex-k-archive.past
/
tex-k-archive.gz
/
tex-k-archive
/
000046_fj@iesd.auc.dk_Tue Oct 12 15:54:44 1993.msg
< prev
next >
Wrap
Internet Message Format
|
1994-10-11
|
6KB
Received: from iesd.auc.dk by cs.umb.edu with SMTP id AA26621
(5.65c/IDA-1.4.4 for <tex-k@cs.umb.edu>); Tue, 12 Oct 1993 09:55:19 -0400
Received: from loke.iesd.auc.dk by iesd.auc.dk with SMTP id AA24168
(5.65c8/IDA-1.5/MD for <tex-k@cs.umb.edu>); Tue, 12 Oct 1993 14:53:32 +0100
Received: by loke.iesd.auc.dk id AA16877
(5.65c8/IDA-CLIENT/MD); Tue, 12 Oct 1993 14:54:44 +0100
Date: Tue, 12 Oct 1993 14:54:44 +0100
From: Frank Jensen <fj@iesd.auc.dk>
Message-Id: <199310121354.AA16877@loke.iesd.auc.dk>
To: tex-k@cs.umb.edu
Subject: Speed of (recursive) search in the Kpathsearch library
I'm sure most people have noticed the delay due to the recursive
search of subdirectories when TeX starts up. [Our users certainly
have as they have started to make private copies of the style files
they need and abandon the search of the `global' style directories.]
At our site, we have in the TeX `inputs' directory approximately 1500
files distributed in 75 directories (and only very few of the ordinary
files are located in non-leaf directories). And this hierarchy is
getting larger, not smaller. This takes a noticable amount of time to
search despite the clever trick Karl uses to speed it up.
So I tried to see how much I could speed up the search by having a
precompiled list of all input files available in a directory
hierarchy. I assumed this list to be a simple text file in the format
produced by the (GNU) `ls' command with option `-R', and that the file
would be located at the root of the hierarchy and named "ls-R". And
IMO, the results are promising: the start up + search is (for all
practical purposes) instantaneous.
I only modified two files: `pathsearch.c' and `elt-dirs.c'. [I have
appended diffs for the changes below. I can of course supply complete
copies of the files, if needed.] I only made the absolute minimum of
changes to make it work. It hasn't been tuned: for example, the
"ls-R" file is read every time, we search for a file; it should only
be read the first time.
Anyway, I think something like this is worthwhile despite the need to
maintain an extra file. What do you think?
---
Frank Jensen, fj@iesd.auc.dk
Department of Mathematics and Computer Science
Aalborg University
DENMARK
*** pathsearch.c Sat Sep 25 20:13:28 1993
--- pathsearch.c.new Mon Oct 11 19:03:22 1993
***************
*** 18,23 ****
--- 18,26 ----
#include <kpathsea/config.h>
+ #include <kpathsea/c-fopen.h>
+ #include <kpathsea/line.h>
+ #include <kpathsea/c-pathch.h>
#include <kpathsea/absolute.h>
#include <kpathsea/expand.h>
#include <kpathsea/pathsearch.h>
***************
*** 58,76 ****
XRETALLOC (potential, allocated, char);
}
! strcpy (potential, dir);
! strcat (potential, name);
! if (kpse_readable_file (potential))
! { /* Found a file. Maybe one is all the caller wants. */
! str_list_add (&ret, potential);
! if (!search_all)
! /* No need to terminate with NULL; the caller knows. */
! return ret;
!
! /* Start new filename. */
! allocated = INIT_ALLOC;
! potential = xmalloc (allocated);
}
}
--- 61,124 ----
XRETALLOC (potential, allocated, char);
}
! if (IS_DIR_SEP (dir[dir_len - 2]))
! { /* search "ls-R" file */
! char file_name[1000]; /* arbitrary length */
! string p = file_name + dir_len - 1, q = p;
! FILE *ls_R_file;
! char *l;
!
! strcpy (file_name, dir);
! strcpy (p, "ls-R");
! ls_R_file = xfopen (file_name, FOPEN_R_MODE);
! while ((l = read_line (ls_R_file)) != NULL)
! {
! int llen = strlen (l);
!
! if (llen > 0)
! if (l[llen - 1] == ':')
! { /* new directory */
! l[llen - 1] = DIR_SEP;
! strcpy (p, l);
! q = p + llen;
! }
! else if (strcmp (l, name) == 0)
! { /* we expect a file to be found now */
! strcpy (q, l);
! if (kpse_readable_file (file_name)) /* just to check */
! { /* Found a file; maybe one is all the caller wants. */
! str_list_add (&ret, xstrdup (file_name));
! if (!search_all)
! { /* No need to terminate with NULL;
! the caller knows. */
! free (l);
! strcpy (p, "ls-R");
! xfclose (ls_R_file, file_name);
! return ret;
! }
! }
! }
! free (l);
! }
! strcpy (p, "ls-R");
! xfclose (ls_R_file, file_name);
! }
! else
! {
! strcpy (potential, dir);
! strcat (potential, name);
! if (kpse_readable_file (potential))
! { /* Found a file. Maybe one is all the caller wants. */
! str_list_add (&ret, potential);
! if (!search_all)
! /* No need to terminate with NULL; the caller knows. */
! return ret;
!
! /* Start new filename. */
! allocated = INIT_ALLOC;
! potential = xmalloc (allocated);
! }
}
}
*** elt-dirs.c Wed Aug 4 01:42:20 1993
--- elt-dirs.c.new Mon Oct 11 19:15:14 1993
***************
*** 224,231 ****
/* If two consecutive directory separators, find subdirectories. */
if (IS_DIR_SEP (dir[1]))
{
! do_subdir (str_list_ptr, elt, dir - elt + 1, dir + 2);
! found_special = true;
}
/* If /?, make following component optional. */
--- 224,237 ----
/* If two consecutive directory separators, find subdirectories. */
if (IS_DIR_SEP (dir[1]))
{
! char ls_R[1000]; /* arbitrary length */
! strncpy (ls_R, elt, dir - elt + 1);
! strcpy (ls_R + (dir - elt + 1), "ls-R");
! if (!kpse_readable_file (ls_R))
! {
! do_subdir (str_list_ptr, elt, dir - elt + 1, dir + 2);
! found_special = true;
! }
}
/* If /?, make following component optional. */